
from flask import Flask, jsonify
from flasgger import Swagger

app = Flask(__name__)
swagger = Swagger(app)

@app.route('/api/<string:username>', methods=['GET'])
def get_user(username):
    """
    获取用户信息
    ---
    tags:
      - 用户管理
    parameters:
      - name: username
        in: path
        type: string
        required: true
        description: 用户名
    responses:
      200:
        description: 返回用户信息
        schema:
          id: user
          properties:
            username:
              type: string
              description: 用户名
            email:
              type: string
              description: 用户邮箱
    """
    return jsonify({
        'username': username,
        'email': f"{username}@example.com"
    })

@app.route('/api/items/<int:item_id>', methods=['GET'])
def get_item(item_id):
    """
    获取项目详情
    ---
    tags:
      - 项目管理
    parameters:
      - name: item_id
        in: path
        type: integer
        required: true
        description: 项目ID
    responses:
      200:
        description: 返回项目信息
        schema:
          id: item
          properties:
            id:
              type: integer
              description: 项目ID
            name:
              type: string
              description: 项目名称
    """
    return jsonify({
        'id': item_id,
        'name': f"Item {item_id}"
    })

if __name__ == '__main__':
    app.run(debug=True)
